// pages/updateuser/updateuser.js
var util = require('../../utils/util.js')
var app = getApp();
Page({
  data: {

    dialog4: {
      hidden: true
    },
    dialog5: {
      hidden: true
    },
    id:{

    },
    dialog2: { hidden: true },
    dialog3: { hidden: true },
    ynameHidden: { hidden: true },
    yphoneHidden: { hidden: true },
    yfilenameHidden: { hidden: true },
    ydetailedHidden: { hidden: true },
    yfangjianhao: { hidden: true },
    yaddressHidden: { hidden: true },
    imageHidden: { hidden: true },
    systemHidden: { hidden: true },
    longlatitudeHidden: { hidden: true },
    yfangjianhao2: { hidden: true },
    upload: { hidden: true },
    loHidden: { hidden: true }
  },
 
  

  onLoad: function (options) {
    
    // 页面初始化 options为页面跳转所带来的参数
    var yid = options.id;
    this.setData({
      id: yid,
    })

  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  //图片选择1
  uploads: function () {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['compressed'],
      //sizeType: ['original', 'compressed'],   // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'],         // 可以指定来源是相册还是相机，默认二者都有
      success: function (res1) {
        wx.uploadFile({
          url: util.getBasePath() + "/ccCustomerApiController/uploadPhoto",
          filePath: res1.tempFilePaths[0],
          name: 'file',
          success: function (res) {

            var s = JSON.parse(res.data);
            if (s.retCode == "500") {
              console.log("不是人脸图片");
              that.setData({ 'imageHidden.hidden': false });
              that.setData({ 'dialog4.hidden': true })
            } else if (s.retCode == "200") {
              var retCode = s.retCode;
              var url = s.retDetail.photoFileId;
              app.imgurl = url;//////12123113/////fds//////413116545153646456454653155635412122112121dfsdsafd4564fdsfdsafdsfafdsfdsfdsfdgdbvb4664645
              console.log("是人脸图片");
              that.setData({ 'dialog4.hidden': true })
              that.setData({
                yfilename: res1.tempFilePaths[0],
              })

            }
          }
        })
      }
    })
  },

  //更新图片
  upusertophone: function (e) {
  var thisto = this;
  var id = this.data.id;
  var url = getApp().imgurl;
  var data = { customerNo: id, photoRrl: url };
  util.ajax("post", "/smallRoutineController/upuserphoneurl", data, function (res) {
    debugger;
    if (res.returnMsg.cookma == "200") {
      if (res.returnMsg.ynumber == "01") {
        console.log("插入数据成功")
        wx.redirectTo({
          url: '../../pages/newshowuser/newshowuser?ynumber=' + wx.getStorageSync("developer")//直接取值
        })
        }
        else{
        console.log("插入数据失败") 
        }
      }else{
        console.log("出现异常")
      }
  })

 
  
  },
  //提示语句
  loChange: function (e) {
    this.setData({
      loHidden: {
        hidden: true
      }
    });
  },
  //提示语句
  systemChange: function (e) {
    this.setData({
      systemHidden: {
        hidden: true
      }
    });
  },
  //提示语句
  yfilenameChange: function (e) {
    this.setData({
      yfilenameHidden: {
        hidden: true
      }
    });
  },
  //提示语句
  imageChange: function (e) {
    this.setData({
      imageHidden: {
        hidden: true
      }
    });
  }
})